package com.guguju.ssms.utils;

/**
 * Created by dell on 2022-5-15.
 */
public class ClicksUtil {

    private static long LAST_CLICLK_TIME;

    /**
     * 快速点击  100毫秒秒之内
     *
     * @return 是否拦截
     */
    public static boolean isFastDoubleClick100() {
        long time = System.currentTimeMillis();
        long timeD = time - LAST_CLICLK_TIME;
        if (0 < timeD && timeD < 1000) {
            return true;
        }
        LAST_CLICLK_TIME = time;
        return false;
    }

    /**
     * 快速点击  1000毫秒秒之内
     *
     * @return 是否拦截
     */
    public static boolean isFastDoubleClick1000() {
        long time = System.currentTimeMillis();
        long timeD = time - LAST_CLICLK_TIME;
        if (0 < timeD && timeD < 1000) {
            return true;
        }
        LAST_CLICLK_TIME = time;
        return false;
    }

    /**
     * 是否是同时点击
     *
     * @return 是否拦截
     */
    public static boolean isSyncDoubleClick() {
        long time = System.currentTimeMillis();
        long timeD = time - LAST_CLICLK_TIME;
        if (timeD == 0) {
            return true;
        }
        LAST_CLICLK_TIME = time;
        return false;
    }
}
